﻿using System.Collections.Generic;
using PCC.App.Properties;
using PCC.Notification;

namespace PCC.App.Notification
{
    public class NotificationSystem : INotificationSystem
    {
        public string SmtpFromEMail
        {
            get { return Settings.Default.SmtpFrom; }
        }

        public string SmtpHost
        {
            get { return Settings.Default.SmtpHost; }
        }

        public int SmtpPort
        {
            get { return Settings.Default.SmtpPort; }
        }

        public string SmtpUsername
        {
            get { return Settings.Default.SmtpUsername; }
        }

        public string SmtpPassword
        {
            get { return Settings.Default.SmtpPassword; }
        }

        public Dictionary<string, INotificationReplacer> Replacers
        {
            get { return _replacers; }
        }

        public Dictionary<string, string> Notification { get; set; }

        public string Process(string text)
        {
            return text;
            //return Replacers.Aggregate(text, (current, notificationReplacer) => notificationReplacer.Value.Replace(current));
        }

        readonly Dictionary<string, INotificationReplacer> _replacers;

        public NotificationSystem()
        {
            // Load replacers
            _replacers = new Dictionary<string, INotificationReplacer>();
            //Utility
            //    .GetAllTypes<INotificationReplacer>()
            //    .ToList()
            //    .ForEach(r => _replacers.Add(r.Key, r));

            // Load notifications' content
            Notification = new Dictionary<string, string>
                               {
                                   {"Activation", Resources.Activation},
                                   {"Offer", Resources.Offer}
                               };
        }
    }
}